<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User_Model extends Base_Model {
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
		$this->load->helper('security');
		$this->load->library('encrypt');
		$this->table_name = "pro_usr";
		$this->primary_key = "user";
		$this->unique_key = "user";
    }
	
	function login()
	{
		$username = $_POST['username'];
		//$password = do_hash($_POST['password'], 'md5');
		$password = $_POST['password'];
		$query= $this->db->get_where($this->table_name, array('pwd'=>$password, 'user'=>$username, 'aktif'=>1));
		return ($query->num_rows() > 0);
	}
	
	function get_post_data()
	{
		$insert = array(
		   'user' => $_POST['username'] ,
		   'level' => $_POST['level'] ,
		   'pwd' => do_hash($_POST['password'], 'md5')
		);
		return $insert;
	}
	
	function add()
	{
		$insert = $this->get_post_data();
		return parent::add($insert);
	}
	
	function edit()
	{
		$insert = $this->get_post_data();
		return parent::edit($insert);
	}
}
/* End of User Model */
/* 26 Juli 2012 [12:13 PM] */
?>